#!/usr/bin/node

const Koa = require('koa');

const app = new Koa();

// M-logger中间件
app.use((ctx, next) => {    //M-logger
  //parse req
  console.log(`${ctx.method} ${ctx.url}`);
  next();
});

app.use((ctx, next) => {     //M-ms
  const start = Date.now();
  next();
  const end = Date.now();
  console.log(`cost: ${end-start}ms `);
});

app.use((ctx, next) => {    //M-hello
  ctx.body = 'hello koa';
})

app.listen(8080);
console.log('hello world');


